<?php ob_start();session_start();?>
<?php
if (isset($_POST['themhinhanh']))
{
	
		$MaSanPham = $_POST['MaSanPham'];	
		$name="../Another/Images/SanPham/".$_FILES['HinhAnh']['name'];	
			
		if($MaSanPham)
		{
			include_once "connection.php";
			$sql="Select * from hinhanh where DuongDan='".$name."'";
			$KT=mysql_query($sql);
			
			if(mysql_num_rows($KT)!=0)
			{
				echo"Hình ảnh <img src='".$name."'/> đã tồn tại, nhập hình ảnh khác</br>";
			}
			else
			{
				$query="Insert into hinhanh(MaSanPham, DuongDan)values('".$MaSanPham."','".$name."')";
				$result=mysql_query($query);	
			}
			header("location:../MyModel/TrangAdmin_con.php?themhinh");
			mysql_close($con);
		}
			
	}
?>
